{extend name="platform/base" /}
{block name='right_title'}
<div class="ncsc-path">
				<i class="icon-desktop"></i>{$title_name} <i class="icon-angle-right"></i>
				<a href="">个人资料</a>
				
			</div>{/block}
{block name='teble_nenu'}
	<div class="tabmenu">
				<ul class="tab pngFix">
					
					<li class="active"><a href="">个人资料</a></li>
					
				</ul>
				<div class="right_side_operation">
					<ul>
						{block name="right_tab"}
						<li><a class="nscs-table-handle_green" href="PLATFORM_MAIN/Auth/addUser" style="display: none;">右侧按钮测试</a></li>
						{/block}
					</ul>
				</div>
			</div>
{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt>用户名:</dt>
		<dd>
			<span class="user_name_span">{$info['user_name']} &nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserName()">修改</a></span>
			<span class="user_name_input" style="display:none;">
				<input name="" id="user_name" type="text" value="{$info['user_name']}"/>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserNameConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserNameCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>头像:</dt>
		<dd>
			<div class="class-Logo"><p><img id="imgLogo"src="__ROOT__/{$info['user_headimg']}" ></p></div>
			<div class="ncsc-upload-btn"> 
			    <a href="javascript:void(0);"><span>
			          <input hidefocus="true" size="1" class="input-file" name="file_upload" id="uploadImg" nc_type="change_store_label" type="file" onchange="imgUpload(this);">
			        <input type="hidden"id="Logo"value="{$info['user_headimg']}"/></span><p><i class="icon-upload-alt"></i>上传图片</p>
			    </a> 
			</div>
			<p class="hint"><br><span style="color:orange;">建议使用宽100像素-高100像素内的GIF或PNG透明图片；点击下方"提交"按钮后生效。</span></p>
		</dd>
	</dl>
	<dl>
		<dt>手机:</dt>
		<dd>
			<span class="user_tel_span">{$info['user_tel']} &nbsp;&nbsp;
				<a href="javascript:;" onclick="updateUserTel()" style='{if condition="$info['user_tel_bind'] eq 1"}display:none;{/if}'>修改</a>&nbsp;&nbsp;
				<a class="user_tel_bind" href="javascript:;" onclick="userTelBind()" style='{if condition="$info['user_tel_bind'] eq 1"}display:none;{/if}'>绑定</a>
				<a class="remove_user_tel_bind" href="javascript:;" onclick="removeUserTelBind()" style='{if condition="$info['user_tel_bind'] eq 0"}display:none;{/if}'>解绑</a>
			</span>
			<span class="user_tel_input" style="display:none;">
				<input name="" id="user_tel" type="text" value="{$info['user_tel']}"/>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserTelConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserTelCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>邮箱:</dt>
		<dd>
			<span class="user_email_span">{$info['user_email']} &nbsp;&nbsp;
				<a href="javascript:;" onclick="updateUserEmail()" style='{if condition="$info['user_email_bind'] eq 1"}display:none;{/if}'>修改</a>&nbsp;&nbsp;
				<a class="user_email_bind" href="javascript:;" onclick="userEmailBind()" style='{if condition="$info['user_email_bind'] eq 1"}display:none;{/if}'>绑定</a>
				<a class="remove_user_email_bind" href="javascript:;" onclick="removeUserEmailBind()" style='{if condition="$info['user_email_bind'] eq 0"}display:none;{/if}'>解绑</a>
			</span>
			<span class="user_email_input" style="display:none;">
				<input name="" id="user_email" type="text" value="{$info['user_email']}"/>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserEmailConfirm()">确定</a>
				&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="updateUserEmailCancel()">取消</a>
			</span>
		</dd>
	</dl>
	<dl>
		<dt>QQ:</dt>
		<dd>
			<input name="" id="user_qq" type="text" value="{$info['user_qq']}" style="width:200px;"/>
		</dd>
	</dl>
	<dl>
		<dt>社交账号:</dt>
		<dd>
<!-- 			<a class="" href="javascript:;"><i class="fa fa-weixin"></i> 绑定微信</a>&nbsp;&nbsp;&nbsp; -->
<!-- 			<a class="" href="javascript:;"><i class="fa fa-weibo"></i> 绑定微博</a>&nbsp;&nbsp;&nbsp; -->
			<span class="user_qq_a" style='{notempty name="info['qq_openid']"}display:none;{/notempty}'><a class="" href="APP_MAIN/login/oauthlogin?type=QQLOGIN"><i class="fa fa-qq"></i> 绑定qq</a></span>
			<span class="user_qq_span" style='{empty name="info['qq_openid']"}display:none;{/empty}'>
				{notempty name="info['qq_openid']"}
				<img alt="" src="{$info['qq_info_array']['figureurl_qq_1']}">
				{/notempty}
				<a class="" href="javascript:removeUserQQBind();"> 解绑</a></span>
		</dd>
	</dl>
	<button class="edit_button" onclick="setUserBasicAjax();">提交</button>
</div>
<script src="ADMIN_JS/ajax_file_upload.js" type="text/javascript"></script>
{include file="platform/openDialog" /}
<script>
function setUserBasicAjax(){
	var user_headimg = $("#Logo").val();
	var user_qq = $("#user_qq").val();
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/userdetail')}",
		data:{
			'user_headimg':user_headimg,
			'user_qq':user_qq,
		},
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/auth/userdetail?type=basic')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 显示 修改邮箱
 */
function updateUserEmail(){
	$(".user_email_span").hide();
	$(".user_email_input").show();
}
//取消
function updateUserEmailCancel(){
	$(".user_email_span").show();
	$(".user_email_input").hide();
}
/**
 * 修改 用户 邮箱
 */
function updateUserEmailConfirm(){
	var user_email = $("#user_email").val();
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/modifyuseremail')}",
		data:{'user_email':user_email},
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 解除 会员邮箱绑定
 */
function removeUserEmailBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/removeuseremailbind')}",
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Auth/userDetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 会员邮箱 绑定
 */
function userEmailBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/Auth/userEmailBind')}",
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Auth/userDetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}


/**
 * 显示手机号
 */
function updateUserTel(){
	$(".user_tel_span").hide();
	$(".user_tel_input").show();
}
//取消
function updateUserTelCancel(){
	$(".user_tel_span").show();
	$(".user_tel_input").hide();
}
/**
 * 修改 用户手机号
 */
function updateUserTelConfirm(){
	var user_tel = $("#user_tel").val();
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/Auth/modifyUserTel')}",
		data:{'user_tel':user_tel},
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Auth/userDetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 解除 会员手机绑定
 */
function removeUserTelBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/removeusertelbind')}",
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],'PLATFORM_MAIN/auth/userdetail');
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 会员手机绑定
 */
function userTelBind(){
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/usertelbind')}",
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 解除 用户 qq 绑定
 */
function removeUserQQBind(){
	$( "#dialog" ).dialog({				
        buttons: {
            "确定,#e57373": function() {
                $(this).dialog('close');
	$.ajax({
		type:"post",
		url:"{:__URL('PLATFORM_MAIN/auth/removeuserqqbind')}",
		async:true,
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/auth/userdetail')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
            },
            "取消": function() {
                $(this).dialog('close');
           
            }
        },
        contentText:"确定解除绑定吗？"
    });	
}
	/**
	*图片上传
	*/
	function imgUpload(event) {
		var fileid = $(event).attr("id");   var str = $(event).next().attr("id");
		$.ajaxFileUpload({
			url : 'PLATFORM_MAIN/System/File_Upload', //用于文件上传的服务器端请求地址
			secureuri : false, //一般设置为false
			fileElementId : fileid, //文件上传空间的id属性  <input type="file" id="file" name="file" />
			dataType : 'text', //返回值类型 一般设置为json
			async : false,
			contentType : "text/json;charset=utf-8",
			success : function(data) //服务器成功响应处理函数
			{
				if (data) {
					$("#imgLogo").attr("src","__ROOT__/"+data);
					$("#Logo").val(data);
					$( "#dialog" ).dialog({
			            buttons: {
			                "确定,#e57373": function() {
			                    $(this).dialog('close');
			                }
			            },
			            contentText:"图片上传成功",
			      		time:1,
			        });
				}else{
					$( "#dialog" ).dialog({
			            buttons: {
			                "确定,#e57373": function() {
			                    $(this).dialog('close');
			                }
			            },
			            contentText:"图片上传失败"
			        });
				}
			}
		});
	}
	/**
	 * 修改会员用户名显示
	 */
	function updateUserName(){
		$(".user_name_span").hide();
		$(".user_name_input").show();
	}
	/**
	 * 修改用户名提交
	 */
	function updateUserNameConfirm(){
		var user_name = $("#user_name").val();
		$.ajax({
			type:"post",
			url:"{:__URL('PLATFORM_MAIN/auth/modifyusername')}",
			data:{
				'user_name':user_name,
			},
			async:true,
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/auth/userdetail')}");
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
	/**
	 * 修改用户名取消
	 */
	function updateUserNameCancel(){
		$(".user_name_span").show();
		$(".user_name_input").hide();
	}
</script>
{/block}